package org.BiteTheDice;
import org.BiteTheDice.R;

import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;

import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

/**
 * run about.xml when called
 * @author barakn01
 */
public class HighScores extends Activity implements OnClickListener {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.highscores);
		TextView view=(TextView) findViewById(R.id.score0);
		view.setText("1st place: "+BiteTheDice.SCORE0);
		view=(TextView) findViewById(R.id.score1);
		view.setText("2nd place: "+BiteTheDice.SCORE1);
		view=(TextView) findViewById(R.id.score2);
		view.setText("3rd place: "+BiteTheDice.SCORE2);
		view=(TextView) findViewById(R.id.score3);
		view.setText("4th place: "+BiteTheDice.SCORE3);
		view=(TextView) findViewById(R.id.score4);
		view.setText("5th place: "+BiteTheDice.SCORE4);
		view=(TextView) findViewById(R.id.score5);
		view.setText("6th place: "+BiteTheDice.SCORE5);
		view=(TextView) findViewById(R.id.score6);
		view.setText("7th place: "+BiteTheDice.SCORE6);
		view=(TextView) findViewById(R.id.score7);
		view.setText("8th place: "+BiteTheDice.SCORE8);
		view=(TextView) findViewById(R.id.score8);
		view.setText("9th place: "+BiteTheDice.SCORE8);
		view=(TextView) findViewById(R.id.score9);
		view.setText("10th place: "+BiteTheDice.SCORE9);
		View delButton = findViewById(R.id.delScores);
		delButton.setOnClickListener(this);
		
	}
	private void delScores(){
		SharedPreferences preferences = getSharedPreferences(BiteTheDice.PREF_FILE_NAME,MODE_PRIVATE);
		SharedPreferences.Editor editor = preferences.edit();
		int newScore=0;
		BiteTheDice.SCORE0=newScore;
		editor.putInt("SCORE0", newScore); // value to store
		
		BiteTheDice.SCORE1=newScore;
		editor.putInt("SCORE1", newScore); // value to store
		
		BiteTheDice.SCORE2=newScore;
		editor.putInt("SCORE2", newScore); // value to store
		
		BiteTheDice.SCORE3=newScore;
		editor.putInt("SCORE3", newScore); // value to store
		
		BiteTheDice.SCORE4=newScore;
		editor.putInt("SCORE4", newScore); // value to store
		
		BiteTheDice.SCORE5=newScore;
		editor.putInt("SCORE5", newScore); // value to store
		
		BiteTheDice.SCORE6=newScore;
		editor.putInt("SCORE6", newScore); // value to store
		
		BiteTheDice.SCORE7=newScore;
		editor.putInt("SCORE7", newScore); // value to store
		
		BiteTheDice.SCORE8=newScore;
		editor.putInt("SCORE8", newScore); // value to store
		
		BiteTheDice.SCORE9=newScore;
		editor.putInt("SCORE9", newScore); // value to store
		
		editor.commit();
		
		TextView view=(TextView) findViewById(R.id.score0);
		view.setText("1st place: "+BiteTheDice.SCORE0);
		view=(TextView) findViewById(R.id.score1);
		view.setText("2nd place: "+BiteTheDice.SCORE1);
		view=(TextView) findViewById(R.id.score2);
		view.setText("3rd place: "+BiteTheDice.SCORE2);
		view=(TextView) findViewById(R.id.score3);
		view.setText("4th place: "+BiteTheDice.SCORE3);
		view=(TextView) findViewById(R.id.score4);
		view.setText("5th place: "+BiteTheDice.SCORE4);
		view=(TextView) findViewById(R.id.score5);
		view.setText("6th place: "+BiteTheDice.SCORE5);
		view=(TextView) findViewById(R.id.score6);
		view.setText("7th place: "+BiteTheDice.SCORE6);
		view=(TextView) findViewById(R.id.score7);
		view.setText("8th place: "+BiteTheDice.SCORE8);
		view=(TextView) findViewById(R.id.score8);
		view.setText("9th place: "+BiteTheDice.SCORE8);
		view=(TextView) findViewById(R.id.score9);
		view.setText("10th place: "+BiteTheDice.SCORE9);
	}

	public void onClick(View v) {
		delScores();
		
	}
	
}
